package com.kotlin.flong.reflection

import kotlin.reflect.full.createInstance
import kotlin.reflect.full.declaredFunctions

/**
 * @Author:liangjl
 * @Date: 2020/7/12-8:52
 * @Eamil:jilongliang@sina.com
 * @Description:
 */
class MyTest13() {
    fun method1(msg: String) {
        println("执行带String参数的方法:$msg")
    }

    fun method2(title: String, price: Double) {
        println("执行带String,Double参数的方法:$title,$price")
    }
}

fun main() {

    var myTest13 = MyTest13::class
    var myObj = myTest13.createInstance()

    var funs = myTest13.declaredFunctions

    for (f in funs) {
        //这里parameters.size等3的时候才会去调用默认两个方法的函数，因为方法是普通方法获取，不是constructor构造方法
        if (f.parameters.size == 3) {
            f.call(myObj, "GoLanguage", 56)
        }
    }
}